﻿<UserControl x:Class="HDInsightStudio.HdfsStudioView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ContextMenu x:Key="treeViewItemMenu">
            <MenuItem Header ="Uplaod" Click="UploadClick"></MenuItem>
            <MenuItem Header ="Create Folder" Click="CreateFolderClick"></MenuItem>
            <MenuItem Header ="Refresh" Click="RefreshClick"></MenuItem>
            <MenuItem Header ="Delete Folder" Click="DeleteFolderClick"></MenuItem>
        </ContextMenu>
        <ContextMenu x:Key="GridItemMenu">
            <MenuItem Header ="Download" Click="DownloadClick"></MenuItem>
            <MenuItem Header ="Delete" Click="DeleteClick"></MenuItem>
        </ContextMenu>
    </UserControl.Resources>
    <Grid>
        <ContentControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib" IsTabStop="False">
            <ContentControl.Resources>
                <ResourceDictionary>
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary Source="/ViewMaker.Core;component/wpf/wpfgenericresource.xaml" />
                        <ResourceDictionary Source="/ViewMaker.Core;component/wpf/wpferrorstyleresource.xaml" />
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
                
            </ContentControl.Resources>
            <Grid Name="HdfsStudio" DataContext="{Binding Mode=OneWay}">
                <Menu FocusManager.IsFocusScope="False">
                    <MenuItem Header="File">
                        <MenuItem Header="Close" Command="{Binding Path=CloseCommand}" />
                    </MenuItem>
                    <MenuItem Header="Job">
                        <MenuItem Header="MapReduce" Command="{Binding Path=MapReduceCommand}"  />
                        <MenuItem Header="Hive" Command="{Binding Path=HiveCommand}" />
                        <MenuItem Header="Jar" Command="{Binding Path=JarMapReduceCommand}" />
                        <MenuItem Header="Sqoop" Command="{Binding Path=SqoopCommand}" />
                    </MenuItem>
                </Menu>
                <!--<StackPanel Name="HdfsStudioButtonPanel" Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="0">
                    <Button Name="DownloadCommand" Command="{Binding Path=DownloadCommand,Mode=OneWay}" Margin="5">ダウンロード</Button>
                    <Button Name="UploadCommand" Command="{Binding Path=UploadCommand,Mode=OneWay}" Margin="5">アップロード</Button>
                    <Button Name="DeleteCommand" Command="{Binding Path=DeleteCommand,Mode=OneWay}" Margin="5">削除</Button>
                    <Button Name="CreateDirectoryCommand" Command="{Binding Path=CreateDirectoryCommand,Mode=OneWay}" Margin="5">ディレクトリ作成</Button>
                    <TextBox Name="Input" Text="{Binding Path=Input, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True }" Width="100" HorizontalAlignment="Left" Margin="5" />
                    <Button Name="ViewCommand" Command="{Binding Path=ViewCommand,Mode=OneWay}" Margin="5">表示</Button>
                    <TextBox Name="ContentEncoding" Text="{Binding Path=ContentEncoding, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True }" ToolTip="エンコーディング" Width="100" HorizontalAlignment="Left" Margin="5" />
                    <Button Name="UpdateCommand" Command="{Binding Path=UpdateCommand,Mode=OneWay}" Margin="5">Refresh</Button>
                    <Button Name="MapReduceCommand" Command="{Binding Path=MapReduceCommand,Mode=OneWay}" Margin="5">Job</Button>
                    <Button Name="HiveCommand" Command="{Binding Path=HiveCommand,Mode=OneWay}" Margin="5">Hive</Button>
                    <Button Name="JarMapReduceCommand" Command="{Binding Path=JarMapReduceCommand,Mode=OneWay}" Margin="5">Jar</Button>
                </StackPanel>-->
                <Grid Name="HdfsStudioDataPanel" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="0">
                    <TreeView Name="Children" ItemsSource="{Binding Path=Children,Mode=OneWay}" vg:TreeViewSelectedItemChangedBehavior.Command="{Binding Path=SelectedItemChangedCommand, Mode=OneWay}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="0" xmlns:vg="clr-namespace:ViewMaker.Core.Wpf;assembly=ViewMaker.Core">
                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding Path=Children,Mode=OneWay}">
                                <StackPanel Orientation="Horizontal" Height="20">
                                    <Image Source="Images/folder.png"   />
                                    <TextBlock Text="{Binding Path=Name,Mode=OneWay}" />
                                </StackPanel>
                            </HierarchicalDataTemplate>
                        </TreeView.ItemTemplate>
                        <TreeView.ItemContainerStyle>
                            <Style TargetType="{x:Type TreeViewItem}">
                                <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                                <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                                <Setter Property="FontWeight" Value="Normal" />
                                <Setter Property="ContextMenu" Value="{StaticResource treeViewItemMenu}" />
                                <EventSetter Event="TreeViewItem.MouseRightButtonDown" Handler="TreeViewItem_MouseRightButtonDown"/>
                                <Style.Triggers>
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter Property="FontWeight" Value="Bold" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </TreeView.ItemContainerStyle>
                    </TreeView>
                    <StackPanel Name="FolderItem" Orientation="Vertical" VerticalAlignment="Stretch" Grid.Row="0" Grid.Column="1">
                        <DataGrid Name="Files" AutoGenerateColumns="false" ItemsSource="{Binding Path=Files,Mode=OneWay}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                             ContextMenu="{StaticResource GridItemMenu}" SelectionUnit="FullRow" MouseDoubleClick="Files_MouseDoubleClick" >
                            <DataGrid.Columns>
                                <DataGridTextColumn Binding="{Binding Path=Name,Mode=OneWay}" x:Name="Name" Header="Name" Width="*" />
                            </DataGrid.Columns>
                        </DataGrid>
                    </StackPanel>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="30*" />
                        <ColumnDefinition Width="70*" />
                    </Grid.ColumnDefinitions>
                </Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
            </Grid>
        </ContentControl>
    </Grid>
</UserControl>
